'use strict';

angular.module('Hospital.message', ['ngRoute', 'Hospital.services'])

.config(['$routeProvider', function($routeProvider) {
	console.log($routeProvider);
	$routeProvider.when('/message', {
		templateUrl: 'views/message/message.html'
	});		
}])

.controller('workLogCtrl', ['$location', '$http', '$scope', function($location, $http, $scope) {

	$scope.params = Object.create($scope.config.defaultPageInfo);
	$scope.params.messageStatus = 0;
	$scope.getPage = function(pn) {
		if(!isNaN(pn)) {
			if($scope.params.pn === pn || pn <=0 || pn > $scope.params.pc) {
				return;
			}
			$scope.params.pn = pn;
		}
		$http.post(API_SERVER + 'message/list', $scope.params).success(function(res) {
			console.log(res);
			if (res && res.code === 0) {
				$scope.params.pn =res.pageNo;
				$scope.params.pc = res.pageCnt;
				$scope.workLogList = res.dataList;
				console.log($scope.workLogList);
			}
		});
	};
	$scope.getPage();

}])

.controller('noticeCtrl', ['$location', '$http', '$scope', function($location, $http, $scope) {
	$scope.params = Object.create($scope.config.defaultPageInfo);
	$scope.params.messageStatus = 1;
	$scope.getPage = function(pn) {
		if(!isNaN(pn)) {
			if($scope.params.pn === pn || pn <=0 || pn > $scope.params.pc) {
				return;
			}
			$scope.params.pn = pn;
		}
		$http.post(API_SERVER + 'message/list', $scope.params).success(function(res) {
			console.log(res);
			if (res && res.code === 0) {
				$scope.params.pn =res.pageNo;
				$scope.params.pc = res.pageCnt;
				$scope.workLogList = res.dataList;
				console.log($scope.workLogList);
			}
		});
	};
	$scope.getPage();
}]);